unit OrderProcessor;

interface

uses
  Order, OrderEntry, OrderValidator;

type
  TOrderProcessor = class(TInterfacedObject)
  private
    FOrderValidator: IOrderValidator;
    FOrderEntry: IOrderEntry;
  public
    constructor Create;
    function ProcessOrder(aOrder: TOrder): Boolean;
  end;

implementation

{ TOrderProcessor }


uses Spring.XE.Utils;
constructor TOrderProcessor.Create;
begin

end;

function TOrderProcessor.ProcessOrder(aOrder: TOrder): Boolean;
var
  OrderIsValid: Boolean;
begin
  Result := False;
  OrderIsValid := FOrderValidator.ValidateOrder(aOrder);
  if OrderIsValid then
  begin
    Result := FOrderEntry.EnterOrderIntoDatabase(aOrder);
  end;


    WriteLn('Order has been processed....');

end;

initialization
  TSpringXEUtils.TryRegisterClass(TOrderProcessor);

end.
